<!DOCTYPE html>
<html>
<head lang="zh-CN">
    <meta charset="UTF-8">
    <!--以最新的IE浏览器引擎去渲染-->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <!--如果是双核浏览器，则使用webkit内核渲染-->
    <meta name="renderer" content="webkit"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <title></title>
    <meta name="description" content=""/>
    <meta name="keyword" content=""/>
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico"/>
    <link rel="stylesheet" href="__PUBLIC__/frame/layui/css/layui.css">
    <link rel="stylesheet" href="__PUBLIC__/frame/static/css/style.css">
    <script type="text/javascript" src="__PUBLIC__/js/jquery1.12.4.js"></script>
    <script type="text/javascript" src="__PUBLIC__/frame/layui/layui.js"></script>
    <link rel="icon" href="__PUBLIC__/frame/static/image/code.png">
</head>
<body>
<style>
    .box{
        margin-top: 20px;
        margin-left: 20px;
    }
    .sum{
        float: right;
        margin-right: 20px;
        line-height: 32px;
    }
    .quanxian{
        display: inline-block;
        width: 200px;
    }
    .addquanxian{
        display: inline-block;
        float: left;
    }
    .juzhong{
        width: 270px;
        margin: 0 auto;
    }
    .refresh{
        display: inline-block;
        float: right;
        margin-right: 20px;
    }
</style>
<div class="box">
    <button class="layui-btn layui-btn-normal addquanxian">添加文章</button>
    <button class="layui-btn layui-btn-normal refresh" onclick="refresh()" title="刷新"><i class="layui-icon">&#x1002;</i></button>
    <div class="layui-input-block juzhong">
        <input type="text" name="title" autocomplete="off" placeholder="请输入文章标题" class="layui-input quanxian">
        <button class="layui-btn layui-btn-normal"><i class="layui-icon">&#xe615;</i></button>
    </div>

    <span class="sum">共有数据：<strong>{$count|default=0}</strong> 条</span>
</div>
<div class="layui-fluid">
    <table class="layui-table" style="text-align: center">
        <thead>
        <tr>
            <th style="text-align: center" width="8%">ID</th>
            <th style="text-align: center" width="30%">文章标题</th>
            <th style="text-align: center" width="18%">发布者</th>
            <th style="text-align: center" width="18%">发布时间</th>
            <th style="text-align: center" width="18%">是否显示</th>
            <th style="text-align: center" width="8%">操作</th>
        </tr>
        </thead>
        <tbody>
        <?php foreach($data as $v){?>
        <tr>
            <td><?php echo $v['art_id'] ?></td>

            <td align="left"><?php echo $v['title'] ?></td>
            <td><?php echo $v['realname'] ?></td>
            <td><?php echo date("Y-m-d H:i:s",$v['pubtime'])?></td>
            <td><?php echo $v['action_name'] ?></td>
            <td>
                <a href="javascript:void (0);" onclick="admin_permission_edit(<?php echo $v['id']?>)"><i class="layui-icon">&#xe642;</i></a>
                <a href="javascript:void (0);" onclick="admin_permission_del(this,<?php echo $v['id']?>)"><i class="layui-icon">&#xe640;</i></a>
            </td>
        </tr>
        <?php }?>
        <!--<tr>-->
            <!--<td>张爱玲</td>-->
            <!--<td>汉族</td>-->
            <!--<td>1920-09-30</td>-->
            <!--<td>于千万人之中遇见你所遇见的人，于千万年之中，时间的无涯的荒野里…</td>-->
            <!--<td>于千万人之中遇见你所遇见的人，于千万年之中，时间的无涯的荒野里…</td>-->
            <!--<td>-->
                <!--<a href=""><i class="layui-icon">&#xe642;</i></a>-->
                <!--<a href=""><i class="layui-icon">&#xe640;</i></a>-->
            <!--</td>-->
        <!--</tr>-->
        </tbody>
    </table>
</div>

<script type="text/javascript">
    layui.use(['layer'],function () {
        var layer = layui.layer;
        $('.addquanxian').click(function () {
            layer.open({
                type: 2,
                title: '添加权限节点',
                shadeClose: true,
                shade: 0.5,
                maxmin: true, //开启最大化最小化按钮
                area: ['550px', '400px'],
                content: '/index.php/home/privilege/add'
            });
        })
    });

    //页面刷新
    function refresh() {
        location.replace(location.href);
    }

    //编辑
    function admin_permission_edit(id) {
        layer.open({
            type: 2,
            title: '编辑权限节点',
            shadeClose: true,
            shade: 0.5,
            maxmin: true, //开启最大化最小化按钮
            area: ['550px', '400px'],
            content: '/index.php/home/privilege/edit?id='+id
        })
    }

    //删除
    function admin_permission_del(obj,id){
        layer.confirm('权限删除须谨慎(如果删除父类,子类也会删除)，确认要删除吗？',function(index){
            var url = "/index.php/Home/Privilege/del";
            var data = {id:id};
            $.post(url,data,function(result){
                if(result.status == 1){
                    $(obj).parents("tr").remove();
                    layer.msg(result.message,{icon:1,time:1000});
                }
                if(result.status == 0){
                    layer.msg(result.message);
                }
            },"JSON");
        });
    }
</script>

</body>